#include<stdio.h>

int num, answer;
char flag[22][22] = {0};

void search(int step)
{
      int i, j, k, x, y, valid;
      if(answer < step) answer = step;
      for(i = 0; i < num; i++)
      {
            for(j = 0; j < num; j++)
            {
                  x = i;
                  y = j;
                  valid = 1;
                  if ( flag[i][j] == 'a' || flag[i][j] == 'X') valid = 0;
                  x = i; y = j;
                  while (x >= 0) 
                  {
                        if (flag[x][y] == 'X') break;
                        if (flag[x][y] == 'a') valid = 0;
                        x--;
                  }
                  x = i; y = j;
                  while (x < num) 
                  {
                        if (flag[x][y] == 'X') break;
                        if (flag[x][y] == 'a') valid = 0;
                        x++;
                  }
                  x = i; y = j;
                  while (y >= 0) 
                  {
                        if (flag[x][y] == 'X') break;
                        if (flag[x][y] == 'a') valid = 0;
                        y--;
                  }
                  x = i; y = j;
                  while (y < num) 
                  {
                        if (flag[x][y] == 'X') break;
                        if (flag[x][y] == 'a') valid = 0;
                        y++;
                  }
                  
                  
                  if(valid == 1)
                  {
                      flag[i][j] = 'a';
                      search(step + 1);
                      flag[i][j] = '.';
                  }
            }
      }
      
      
}
int main()
{
    int i;
    while (1)
    {
        scanf("%d", &num);
        if (num == 0) break;
        for (i = 0; i < num; ++ i)
            scanf("%s", flag[i]);
        answer = 0;
        search(0);
        printf("%d\n",answer);
    }
    return 0;
}
